//
//  VisitorTableViewController.swift
//  Weibo1.0
//
//  Created by 黄礼潮 on 16/2/16.
//  Copyright © 2016年 黄礼潮. All rights reserved.
//

import UIKit


class VisitorTableViewController: UITableViewController {

    private var userperson = false
    
    var visitorView:VisitorView?  //定义视图的属性
    
    override func loadView() {
        
     userperson ? super.loadView() : setupVisitorView()
       
        
    }
    
    
    private func setupVisitorView(){
    
         visitorView = VisitorView()
         view = visitorView
        
        //添加监听方法
        visitorView?.registerButon.addTarget(self, action: "visitorViewDidRegister", forControlEvents: .TouchUpInside)
        visitorView?.loginButon.addTarget(self, action: "visitorViewDidLogin", forControlEvents: .TouchUpInside)
        
       // UINavigationBar.appearance().tintColor = UIColor.orangeColor()
         //一定要在创建之前把外观设置好，不然刚开始是蓝的
        //添加导航栏按钮
      
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorViewDidRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "visitorViewDidLogin")
           }
   
}

extension VisitorTableViewController{

    func visitorViewDidRegister(){
    
      print("注册")
    
    }
    func visitorViewDidLogin(){
        
        let vc = OAuthViewController()
        
        let nav = UINavigationController(rootViewController: vc)
        
//        presentViewController(nav, animated: true) { () -> Void in
//            print("hah")
//        }
        presentViewController(nav, animated: true, completion: nil)
        
    }
    
    
}


